package com.ceshiren.hogwarts.app.contact;

import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.net.URL;
import java.util.concurrent.TimeUnit;

public class MainPage extends BasePage {

    public MainPage() throws Exception{
        System.out.println ("==========" );
        this.initData();
    }

    public void initData() throws Exception {
        DesiredCapabilities caps = new DesiredCapabilities();
        caps.setCapability("platformName", "android");
//        caps.setCapability("udid", "emulator-5554");
        caps.setCapability("deviceName", "127.0.0.1:7555");
        caps.setCapability("appPackage", "com.tencent.wework");
        caps.setCapability("appActivity", ".launch.WwMainActivity");
        caps.setCapability("noReset", "true");
        androidDriver = new AndroidDriver<> (new URL("http://localhost:4723/wd/hub"), caps);
        androidDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    }

    public ContactPage contactPage() throws Exception{
        System.out.println ("tong xun lu ==========");
        Thread.sleep (20000L);
        click(By.xpath("//*[@text='通讯录']"));
        return new ContactPage(androidDriver);
    }

}
